<?php


/**
* Puree CMS
* http://www.molotsoft.ru
*
* @package Puree_CMS
* @subpackage Elements
* @author Ivan Chistyakov <ivan@molotsoft.ru>
* @version $Id: admin_view_default_tab.ctp 682 2010-03-01 12:55:13Z molotsoft@gmail.com $
* @link $HeadURL: http://puree-cms.googlecode.com/svn/trunk/views/elements/automate/admin_view_default_tab.ctp $
*/


// form_tab_panel-tab_name
echo '<div id="' . $tab_name . '" class="form_tab_panel form_tab_panel-' . $tab_name . ' form_fields">';
switch ($tab_description['type']) {
	case 'frame': {
		echo '<iframe name="' . $tab_name . '_frame" src="' . addslashes($html->url($tab_description['url'])) . '" frameborder="no" class="form_tab_panel_frame"></iframe>';
		break;
	}
	case 'attachment': {
		echo '<iframe name="' . $tab_name . '_frame" src="' . addslashes($html->url(array('controller' => Inflector::tableize($tab_description['model']), 'action' => 'index', 'model' => $model, 'foreign_key' => $id, 'ext' => 'frame'))) . '" frameborder="no" class="form_tab_panel_frame"></iframe>';
		break;
	}
	default: {
		foreach ($tab_description['field_schema'] as $field_name => $field_description) {
			// form_field (admin_view_field_<name>.ctp | admin_view_default_field.ctp)
			if (fileExistsInPath(ELEMENTS . $controller . DS . 'admin_view_field_' . $field_name . $this->ext)) {
				echo $this->element($controller . DS . 'admin_view_field_' . $field_name, array('field_name' => $field_name, 'field_description' => $field_description));
			} elseif (fileExistsInPath(ELEMENTS . 'automate' . DS . 'admin_view_field_' . $field_name . $this->ext)) {
				echo $this->element('automate' . DS . 'admin_view_field_' . $field_name, array('field_name' => $field_name, 'field_description' => $field_description));
			} elseif (fileExistsInPath(ELEMENTS . $controller . DS . 'admin_view_default_field' . $this->ext)) {
				echo $this->element($controller . DS . 'admin_view_default_field', array('field_name' => $field_name, 'field_description' => $field_description));
			} elseif (fileExistsInPath(ELEMENTS . 'automate' . DS . 'admin_view_default_field' . $this->ext)) {
				echo $this->element('automate' . DS . 'admin_view_default_field', array('field_name' => $field_name, 'field_description' => $field_description));
			/*} else {
				switch ($field_description['input']['type']) {
					case 'skip': break;
					case 'static': if (isset($this->data[$model][$field_name])) echo '<div class="form_field form_field_static"><label>' . $field_description['input']['label'] . '</label><span class="static">' . $this->data[$model][$field_name] . '</span></div>'; break;
					case 'image':
					case 'file':
					case 'audio':
					case 'video': {
						$field_description['input']['div'] = 'form_field form_field_text';
						$field_description['input']['type'] = 'text';
						echo $form->input($field_name, $field_description['input']);
						break;
					}
					default: {
						$field_description['input']['div'] = 'form_field form_field_' . $field_description['input']['type'];
						echo $form->input($field_name, $field_description['input']);
						break;
					}
				}*/
			}
		}
		break;
	}
}
echo '</div>'; // end of form_tab_panel-tab_name


?>